package jp.mixi.android.sdk.hackathon.entity;

import jp.mixi.android.sdk.hackathon.util.JSONObjectUtil;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;

public class People implements Serializable {

    private JSONObject original;

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    public People(JSONObject obj) {
        original = obj;
    }

    public void setPeople(People p) {
        original = p.original;
    }
    public People(String src) {
        try {
            JSONObject root = new JSONObject(src);
            original = root.getJSONObject("entry");
            
        } catch (JSONException e) {
            throw new IllegalArgumentException("not json", e);
        }
    }

    public String getId() {
        return JSONObjectUtil.getStringByName(original, "id");
    }

    public String getDisplayName() {
        return JSONObjectUtil.getStringByName(original, "displayName");
    }

    public final String getProfileUrl() {
        return JSONObjectUtil.getStringByName(original, "profileUrl");
    }

    public final String getThumbnailUrl() {
        return JSONObjectUtil.getStringByName(original, "thumbnailUrl");
    }

    public final String getGender() {
        return JSONObjectUtil.getStringByName(original, "gender");
    }

    public final String getFieldByName(String name) {
        return JSONObjectUtil.getStringByName(original, name);
    }

    public String toString() {
        return getDisplayName();
    }
}


